CREATE TABLE [dbo].[CLIENTES]
(
[ID] [numeric] (10, 0) NOT NULL,
[CLIENTE] [varchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[NOMBRE_COMERCIAL] [varchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[DIRECCION] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[ID_CIUDAD] [numeric] (10, 0) NOT NULL,
[ID_VENDEDOR] [numeric] (10, 0) NOT NULL,
[RNC] [varchar] (11) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[TELEFONO] [varchar] (14) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_CLIENTES_TELEFONO] DEFAULT ((0)),
[CELULAR] [varchar] (14) COLLATE SQL_Latin1_General_CP1_CI_AS NULL CONSTRAINT [DF_CLIENTES_CELULAR] DEFAULT ((0)),
[FAX] [varchar] (14) COLLATE SQL_Latin1_General_CP1_CI_AS NULL CONSTRAINT [DF_CLIENTES_FAX] DEFAULT ((0)),
[OTRO] [varchar] (14) COLLATE SQL_Latin1_General_CP1_CI_AS NULL CONSTRAINT [DF_CLIENTES_OTRO] DEFAULT ((0)),
[EMAIL] [varchar] (80) COLLATE SQL_Latin1_General_CP1_CI_AS NULL CONSTRAINT [DF_CLIENTES_EMAIL] DEFAULT (''),
[FECHA] [datetime2] (0) NOT NULL CONSTRAINT [DF_CLIENTES_FECHA] DEFAULT (getdate()),
[OBSERVACIONES] [varchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NULL CONSTRAINT [DF_CLIENTES_OBSERVACIONES] DEFAULT (''),
[LIMITE_CREDITO] [numeric] (10, 2) NULL CONSTRAINT [DF_CLIENTES_LIMITE_CREDITO] DEFAULT ((0)),
[ACTIVO] [bit] NOT NULL CONSTRAINT [DF_CLIENTES_ACTIVO] DEFAULT ((1)),
[ID_CATEGORIA] [numeric] (10, 0) NOT NULL,
[ID_ZONA] [numeric] (10, 0) NULL,
[ID_RUTA] [numeric] (10, 0) NULL,
[ID_FORMA_PAGO] [numeric] (10, 0) NOT NULL,
[IMPUESTOS] [bit] NOT NULL CONSTRAINT [DF_CLIENTES_IMPUESTOS] DEFAULT ((1)),
[MONTO_ADEUDADO] [decimal] (10, 2) NOT NULL CONSTRAINT [DF_CLIENTES_MONTO_ADEUDADO] DEFAULT ((0))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[CLIENTES] ADD CONSTRAINT [PK_CLIENTES] PRIMARY KEY CLUSTERED  ([ID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_CLIENTES] ON [dbo].[CLIENTES] ([RNC]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[CLIENTES] ADD CONSTRAINT [FK_CLIENTES_CLIENTES_CAT] FOREIGN KEY ([ID_CATEGORIA]) REFERENCES [dbo].[CLIENTES_CAT] ([ID])
GO
ALTER TABLE [dbo].[CLIENTES] ADD CONSTRAINT [FK_CLIENTES_CIUDADES] FOREIGN KEY ([ID_CIUDAD]) REFERENCES [dbo].[CIUDADES] ([ID])
GO
ALTER TABLE [dbo].[CLIENTES] ADD CONSTRAINT [FK_CLIENTES_PLAZOS_PAGOS] FOREIGN KEY ([ID_FORMA_PAGO]) REFERENCES [dbo].[FORMAS_PAGOS] ([ID])
GO
ALTER TABLE [dbo].[CLIENTES] ADD CONSTRAINT [FK_CLIENTES_RUTAS] FOREIGN KEY ([ID_RUTA]) REFERENCES [dbo].[RUTAS] ([ID])
GO
ALTER TABLE [dbo].[CLIENTES] ADD CONSTRAINT [FK_CLIENTES_VENDEDORES] FOREIGN KEY ([ID_VENDEDOR]) REFERENCES [dbo].[VENDEDORES] ([ID])
GO
ALTER TABLE [dbo].[CLIENTES] ADD CONSTRAINT [FK_CLIENTES_ZONAS] FOREIGN KEY ([ID_ZONA]) REFERENCES [dbo].[ZONAS] ([ID])
GO
